package com.mc.lp.database.entity;

import java.sql.Blob;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;



@NamedNativeQueries({
	@NamedNativeQuery(
	name = "fetchAttachmentWithoutDataNativeSQL",
	query = "select * from ATTACHMENT where s.stock_code = :stockCode",
        resultClass = AttachmentEntity.class
	)
})

@Entity
@Table(name="ATTACHMENT")
public class AttachmentEntity extends MicroCampusBaseEntity{

	private static final long serialVersionUID = 1L;
	
	@OneToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ENTITY_ID")
	private MicroCampusEntity entityId;
	
	@Column(name="RECORD_ID")
	private Long recordId;
	
	@Column(name="RECORD_TYPE_ID")
	private Long recordTypeId;
	
	@Column(name="YEAR")
	private int year;
	
	@Column(name="TERM_ID")
	private int termId;
	
	@Column(name="GRADE_ID")
	private int gradeId;
	
	@Column(name="FILE_DATA")
	@Lob
	@Basic(fetch=FetchType.LAZY)
	private Blob data;
	
	@Column(name="FILE_NAME")
	private String name;
	
	
	public MicroCampusEntity getEntityId() {
		return entityId;
	}
	public void setEntityId(MicroCampusEntity entityId) {
		this.entityId = entityId;
	}
	public Long getRecordId() {
		return recordId;
	}
	public void setRecordId(Long recordId) {
		this.recordId = recordId;
	}
	public Long getRecordTypeId() {
		return recordTypeId;
	}
	public void setRecordTypeId(Long recordTypeId) {
		this.recordTypeId = recordTypeId;
	}
	public int getYear() {
		return year;
	}
	public void setYear(int year) {
		this.year = year;
	}
	public int getTermId() {
		return termId;
	}
	public void setTermId(int termId) {
		this.termId = termId;
	}
	public int getGradeId() {
		return gradeId;
	}
	public void setGradeId(int gradeId) {
		this.gradeId = gradeId;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	
	public Blob getData() {
		return data;
	}
	public void setData(Blob data) {
		this.data = data;
	}
	@Override
	public String toString() {
		return "AttachmentEntity [entityId=" + entityId + ", recordId=" + recordId
				+ ", recordTypeId=" + recordTypeId + ", year=" + year + ", termId=" + termId
				+ ", gradeId=" + gradeId + ", name=" + name + "]";
	}
	
	
	
}
